package com.yaoq.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @ClassName OutPutImpl
 * @Description TODO
 * @Author yaoqiang
 * @Date 2020/9/9 16:49
 * @Version 1.0
 */
public class OutPutImpl {
    List<College> collegeList;

    public OutPutImpl(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    public void printCollege() {
        Iterator<College> iterator = collegeList.iterator();
        while (iterator.hasNext()) {
            College college = iterator.next();
            System.out.println("collegeName" + college.getName());
            printDepartment(college.createIterator());
        }
    }

    private void printDepartment(Iterator iterator) {
        while (iterator.hasNext()) {
            Department department = (Department) iterator.next();
            System.out.println(department.getName());
        }
    }

}
